<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head th:replace="_fragments::head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="stylesheet" href="../../static/css/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/me.css">

    <title>分类编辑</title>
</head>


<body>

<!--导航-->
<nav th:replace="admin/_fragments::menu(2)" class="ui inverted attached segment"></nav>

<!--二级导航-->
<div class="ui attached pointing menu">
    <div class="ui container">
        <div class="right menu">
            <a th:href="@{/admin/type/save}" href="type-input.html" class="teal active item">编辑</a>
            <a th:href="@{/admin/type}" href="type.html" class="item">列表</a>
        </div>
    </div>
</div>

<br><br><br><br>

<!--中间内容-->
<div class="m-padded-tb-big m-container-small">
    <div class="ui container">
        <form action="#" method="post" class="ui form"
              th:object="${type}"
              th:method="*{id}==null ? POST : PUT"
              th:action="*{id}==null ? @{/admin/type} : @{/admin/type/{id}(id=*{id})}">
            <!--隐藏域：分类 ID-->
            <input type="hidden" name="id" th:value="*{id}">
            <!--分类名称输入框-->
            <div class="required field">
                <div class="ui left labeled input">
                    <label for="name" class="ui teal basic label">名称</label>
                    <input id="name" type="text" name="name" placeholder="请输入分类名称" th:value="*{name}">
                </div>
            </div>
            <!--前端错误提示框-->
            <div class="ui error message"></div>
            <!--后端错误提示框-->
            <!--/*/
            <div th:if="${#fields.hasErrors('name')}" class="ui negative message">
                <i class="close icon"></i>
                <div class="header">校验失败</div>
                <p th:errors="*{name}">提交的信息不符合规则</p>
            </div>
            /*/-->
            <!--返回和提交按钮-->
            <div class="ui right aligned container">
                <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                <button class="ui teal submit button">提交</button>
            </div>
        </form>
    </div>
</div>


<!--/*/<th:block th:replace="admin/_fragments::script">/*/-->
<script src="../../static/js/jquery.min.js"></script>
<script src="../../static/js/semantic.min.js"></script>
<!--/*/</th:block>/*/-->

<script>
    $('.ui.form').form({
        fields: {
            name: {
                identifier: 'name',
                rules: [{
                    type: 'empty',
                    prompt: '请输入分类名称'
                }]
            }
        }
    });
</script>
</body>
</html>